Skip to content

STRATCONN-6780 - [Pinterest CAPI] - new events and fields#3820

Open
joe-ayoub-segment wants to merge 16 commits into
mainfrom
pinterest-new-events
Open

STRATCONN-6780 - [Pinterest CAPI] - new events and fields#3820
joe-ayoub-segment wants to merge 16 commits into
mainfrom
pinterest-new-events

Conversation

@joe-ayoub-segment

@joe-ayoub-segment joe-ayoub-segment commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Pinterest CAPI destiantion - adding support for new events and fields.

  • Adds all new Pinterest conversion event types: add_payment_info, add_to_wishlist, app_install, app_open,
    contact, customize_product, find_location, initiate_checkout, schedule, start_trial, submit_application,
    subscribe, view_content
  • Adds new fields requested by Pinterest: advertiser_tracking_enabled, app_info (object), device_info (object),
    custom_data.content_brand, custom_data.content_category, custom_data.content_name, custom_data.predicted_ltv,
    custom_data.np, and contents[].item_brand, contents[].item_brand_id, contents[].item_category,
    contents[].item_name
  • Introduces a "Use Latest Fields" toggle (data_format) that controls field visibility via depends_on:
    • Latest (default for new instances): shows custom_data_2 (flat fields without nested contents), contents
      (standalone array with @arrayPath defaults from Segment ecommerce spec), app_info, and device_info
    • Legacy (or undefined for existing instances): shows the original nested custom_data object and flat app_id,
      app_name, app_version, device_brand, device_carrier, device_model, device_type, os_version fields
  • Existing integrations are unaffected — they have no value for data_format (undefined), which is treated as
    legacy via depends_on conditions
  • Adds presets for new events (Add Payment Info, Add to Wishlist, App Install, App Open, Initiate Checkout, Start
    Trial, Subscribe, View Content) mapped to Segment spec event names
  • Refactors presets and event name choices to reference EVENT_NAME constants
  • Hardcodes np: 'ss-segment' in outbound custom_data (per Pinterest's confirmation that this is the same as
    partner_name)
  • Defines TypeScript types for the outbound Pinterest API payload (PinterestEventPayload,
    LegacyPinterestEventPayload, CustomData, UserData, ContentsItem, AppInfo, DeviceInfo)
  • Converts install_time from ISO8601 datetime to Unix seconds, with guards for numeric pass-through and invalid
    dates
  • Converts predicted_ltv and value from number to string per Pinterest API spec
  • Fixes existing bug where SIGNUP constant was mapped to 'search' instead of 'signup'

Testing

To be tested in Staging

Unt test changes:

Removed:

  • Deleted the snapshot file (snapshots/index.test.ts.snap) — replaced snapshot assertions with explicit body assertions

Restructured existing tests:

  • Split tests into describe('legacy mode') and describe('latest mode') blocks
  • All existing tests now explicitly set data_format: 'legacy' or 'latest'
  • Replaced the hardcoded full-body string assertion (expect(body).toBe('{...}')) with parsed JSON assertions that verify the same hashing
    behavior

New tests added:

  1. undefined data_format (existing subscriptions) — omits data_format from the mapping, verifies legacy behavior (flat app/device fields,
    no app_info/device_info)
  2. install_time conversion — passes an ISO timestamp in app_info.install_time, asserts it's converted to Unix seconds in the output
  3. predicted_ltv conversion — passes a number for predicted_ltv and value, asserts both are converted to strings
  4. empty app_info and device_info omission — passes empty {} for both objects, asserts they're omitted (undefined) in the output
  5. new event names — sends start_trial as event_name, asserts it's accepted and passed through
  6. conditional required field — two sub-tests:
    - Verifies app_name is not required when data_format: 'latest' (succeeds without it)
    - Verifies app_name is required when data_format: 'legacy' (throws without it)

Assertions added to existing tests:

  • advertiser_tracking_enabled asserted in both the legacy mode success test and the latest mode success test

Security Review

Please ensure sensitive data is properly protected in your integration.

  • Reviewed all field definitions for sensitive data (API keys, tokens, passwords, client secrets) and confirmed they use type: 'password'

New Destination Checklist

  • Extracted all action API versions to verioning-info.ts file. example

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds support for additional Pinterest Conversions API (CAPI) fields in the pinterest-conversions destination’s reportConversionEvent action, extending the mapped payload and updating tests/snapshots accordingly.

Changes:

  • Expanded supported event_name choices and updated Pinterest event name constants.
  • Added new payload fields (advertiser_tracking_enabled, app_info, device_info) and new custom_data fields (content_*, predicted_ltv, np) to the outbound request payload.
  • Updated unit tests and snapshots to reflect the new payload shape.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/index.ts Adds new action fields and includes them in the request payload mapping.
packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/generated-types.ts Updates generated Payload typings for new fields.
packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/tests/index.test.ts Updates assertions to validate new payload fields without full-body string equality.
packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/tests/snapshots/index.test.ts.snap Updates snapshots to include newly added payload fields.
packages/destination-actions/src/destinations/pinterest-conversions/pinterest-capi-custom-data.ts Adds new custom_data schema fields (including predicted_ltv).
packages/destination-actions/src/destinations/pinterest-conversions/constants.ts Expands Pinterest event name constants and fixes SIGNUP value.

@joe-ayoub-segment joe-ayoub-segment changed the title STRATCONN-6780 - [Pinterest CAPI] - new fields STRATCONN-6780 - [Pinterest CAPI] - new events and fields Jun 3, 2026
joe-ayoub-segment and others added 2 commits June 3, 2026 12:10
- Map app_info.app_id to context.app.build
- Map device_info.brand to context.device.manufacturer
- Map device_info.carrier to context.network.carrier
- Add window_height/window_width defaults to app_info
- Change install_time to datetime with unix conversion

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 3, 2026 11:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

joe-ayoub-segment and others added 2 commits June 3, 2026 12:34
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 3, 2026 11:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

joe-ayoub-segment and others added 2 commits June 3, 2026 13:09
Introduces a `data_format` choice field that controls field visibility:
- "Structured Fields" (default for new instances): shows flat custom data
  fields, contents array, app_info, and device_info objects
- "Legacy Fields" (or undefined for existing instances): shows the original
  nested custom_data object and flat app/device fields

Existing integrations are unaffected — they have no value for data_format
(undefined), which is treated as legacy via depends_on conditions.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- custom_data_2: object field with all custom data properties except contents
- contents: standalone array field with proper @arrayPath default mapping
- Both defined with depends_on DEPENDS_ON_STRUCTURED
- custom_data_field_2 exported from pinterest-capi-custom-data.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 3, 2026 12:23

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

joe-ayoub-segment and others added 2 commits June 3, 2026 13:29
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 3, 2026 12:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 5 comments.

joe-ayoub-segment and others added 2 commits June 3, 2026 13:52
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 3, 2026 13:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Copilot AI review requested due to automatic review settings June 3, 2026 14:26
@joe-ayoub-segment joe-ayoub-segment added the needs-stage-test Must be tested in Stage before deployment label Jun 3, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

@joe-ayoub-segment joe-ayoub-segment marked this pull request as ready for review June 3, 2026 16:26
@joe-ayoub-segment joe-ayoub-segment requested a review from a team as a code owner June 3, 2026 16:26
Copilot AI review requested due to automatic review settings June 3, 2026 16:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

joe-ayoub-segment and others added 2 commits June 3, 2026 17:41
- Define PinterestEventPayload, LegacyPinterestEventPayload, CustomData,
  UserData, ContentsItem, AppInfo, DeviceInfo in types.ts
- Wire up return types on buildCustomData and createPinterestPayload
- Fix convertInstallTime to handle 0 correctly
- Remove app_id and os_family default mappings
- Add advertiser_tracking_enabled assertions to tests
- Add test for undefined data_format (existing subscriptions)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings June 4, 2026 08:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

packages/destination-actions/src/destinations/pinterest-conversions/reportConversionEvent/index.ts:439

  • The user_data validation rejects payloads that only provide phone, but the error message explicitly lists Phone Number as an accepted identifier. This can cause valid conversions (phone-only) to fail with a 400 IntegrationError.
  if (
    isEmpty(payload.user_data?.email) &&
    isEmpty(payload.user_data?.hashed_maids) &&
    !(payload.user_data?.client_ip_address && payload.user_data?.client_user_agent)
  ) {

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Not ready to approve

There’s a confirmed timestamp conversion bug for numeric-string install_time inputs and a misleading user-facing error message that should be corrected for accuracy.

Copilot's findings
  • Files reviewed: 8/8 changed files
  • Comments generated: 3

Note

Your feedback helps us improve the quality of this feature.
Please use 👍 or 👎 to tell us whether this assessment is correct.

Comment on lines +456 to +462
function convertInstallTime(value: string | number | undefined | null): number | undefined {
if (value === undefined || value === null || value === '') return undefined
if (typeof value === 'number') return value
const parsed = dayjs.utc(value)
if (!parsed.isValid()) return undefined
return parsed.unix()
}
Comment on lines 434 to 436
async function processPayload(request: RequestClient, settings: Settings, payload: Payload) {
if (
isEmpty(payload.user_data?.email) &&
Comment on lines 87 to 100
@@ -141,86 +99,506 @@ describe('PinterestConversionApi', () => {
)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-stage-test Must be tested in Stage before deployment partner-eng-review (cloud)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants